<!-- 语音识别初始化脚本 -->
<script src="../js/voiceRecognition.js"></script>
<script>
// 页面加载完成后自动初始化语音识别
document.addEventListener('DOMContentLoaded', function() {
    // 延迟初始化，确保页面完全加载
    setTimeout(function() {
        if (typeof initVoiceRecognitionForPage === 'function') {
            initVoiceRecognitionForPage();
            console.log('语音识别功能已初始化');
        } else {
            console.warn('语音识别模块未正确加载');
        }
    }, 500);
});

// 为特定的输入元素添加语音识别按钮
function addVoiceToInput(inputSelector) {
    const input = document.querySelector(inputSelector);
    if (input && typeof addVoiceRecognitionToInput === 'function') {
        addVoiceRecognitionToInput(input);
    }
}

// 添加语音识别按钮的样式
const voiceStyle = document.createElement('style');
voiceStyle.textContent = `
.voice-recognition-btn {
    position: absolute !important;
    right: 5px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    border: none !important;
    background: transparent !important;
    font-size: 16px !important;
    cursor: pointer !important;
    padding: 2px 4px !important;
    border-radius: 3px !important;
    z-index: 1000 !important;
    opacity: 0.7 !important;
    transition: opacity 0.2s !important;
}

.voice-recognition-btn:hover {
    opacity: 1 !important;
    background: #f0f0f0 !important;
}

.voice-recognition-btn.recording {
    color: #ff0000 !important;
    animation: voicePulse 1.5s infinite !important;
}

@keyframes voicePulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}
`;
document.head.appendChild(voiceStyle);
</script> 